package com.ebupt.migu.music.unifyAudit.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author tz
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultObject<T> {
    /**
     * 返回编码
     **/
    private String code = "000000";
    /**
     * 返回信息
     **/
    private String info = "success";
    /**
     * 数据
     */
    private T data;

    public ResultObject success(){
        return new ResultObject();
    }

    public ResultObject success(Object data){
        ResultObject res = new ResultObject();
        res.setData(data);
        return res;
    }

    public ResultObject success(String msg,Object data){
        ResultObject res = new ResultObject();
        res.setInfo(msg);
        res.setData(data);
        return res;
    }

    public ResultObject fail(String code,String msg){
        ResultObject res = new ResultObject();
        res.setCode(code);
        res.setInfo(msg);
        return res;
    }
}
